#!/bin/sh
#
# Copyright (C) 2000-2022 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#


cd @regressdir@

if [ ! -d build ] ; then
    echo "Build directory not present, will run make setup"
    cd @regressdir@
    make setup
    exit
fi

cd @regressdir@/build 

touch git-version
cur=`cat git-version`

cd @srcdir@

new=`git show HEAD | grep -m 1 commit | awk '{print $2}'`

cd @regressdir@

echo Build is ${cur}
echo Source is ${new}

if [ ${cur}x != ${new}x ] ; then
    echo "Newer version available, will run make setup"
    git pull
    make setup
else
    echo "Latest version present in build, skipping make setup"
fi
